package com.wanxi.web.controller;

import com.wanxi.coupon.api.query.CouponEnterpriseQuery;
import com.wanxi.coupon.api.query.CouponEnterpriseStatisticQuery;
import com.wanxi.coupon.api.result.CommonResult;
import com.wanxi.coupon.api.vo.CouponEnterpriseTDO;
import com.wanxi.coupon.api.vo.CouponEnterpriseVo;
import com.wanxi.web.service.coupon.CouponWebService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * ClassName: EnterpriseCouponController
 * Description:
 * date: 2022/1/13 10:55
 *
 * @author lxl
 * @version 1.0
 * @since JDK 1.8
 */
@Api(tags = "商家优惠券")
@RestController
@RequestMapping("enterprises/coupon")
public class EnterpriseCouponController {

    @Resource
    private CouponWebService couponWebService;

    /**
     * @Author lxl
     * @Description  商家按条件查询优惠券信息接口
     **/
    @ApiOperation("商家查询优惠券的所有信息")
    @GetMapping("findAll")
    public CommonResult enterpriseFindAll(CouponEnterpriseQuery coupon){
        return couponWebService.enterpriseFindAll(coupon);
    }

    /**
     * @Author lxl
     * @Description  商家按条件查询优惠券统计信息接口
     **/
    @ApiOperation("商家查询优惠券的统计信息")
    @GetMapping("findStatistic")
    public CommonResult enterpriseFindStatistic(CouponEnterpriseStatisticQuery coupon){
        return couponWebService.enterpriseFindStatistic(coupon);
    }

    /**
     * @Author lxl
     * @Description  商家通过id查询优惠券信息接口
     **/
    @ApiOperation("商家通过id查询单个优惠券")
    @ApiImplicitParam(name = "id",value = "要查询的优惠券id",dataType = "Integer")
    @GetMapping("findById")
    public CommonResult <List<CouponEnterpriseVo>> enterpriseFindById(Long id){
        return couponWebService.enterpriseFindById(id);
    }

    /**
     * @Author lxl
     * @Description  商家添加优惠券接口
     **/
    @ApiOperation("商家添加优惠券数据接口")
    @PostMapping("add")
    public CommonResult enterpriseAdd(  CouponEnterpriseTDO coupon){
        return couponWebService.enterpriseAdd(coupon);
    }

    /**
     * @Author lxl
     * @Description  商家通过id删除优惠券信息接口
     **/
    @ApiOperation("商家删除优惠券数据接口")
    @ApiImplicitParam(name = "id",value = "要删除的优惠券的id，",dataType = "Integer")
    @PutMapping("delete")
    public CommonResult enterpriseDelete( Integer id){
        return couponWebService.enterpriseDelete(id);
    }

    /**
     * @Author lxl
     * @Description  商家按条件查询优惠券条数接口
     **/
    @ApiOperation("商家查询优惠券的条数")
    @GetMapping("getCount")
    public CommonResult enterpriseGetCount(CouponEnterpriseQuery coupon){
        return couponWebService.enterpriseGetCount(coupon);
    }
}
